package com.jdk.demo.nio.charbuffer;

import java.nio.CharBuffer;

public class WrapDemo {
	
	// 将字符序列包装到缓冲区中，新的只读缓冲区的内容将为给定字符序列的内容。缓冲区的容量为csq.lengh，位置为start，limit为en
	public static void main(String[] args) {
		CharBuffer charbuffer1 = CharBuffer.wrap("abcdefg", 3, 5);
		System.out.println("charbuffer1 capacity=" + charbuffer1.capacity() + ", position=" + charbuffer1.position() + " limit=" + charbuffer1.limit());
		
		for (int i = charbuffer1.position(); i < charbuffer1.limit(); i++) {
			System.out.print(charbuffer1.get(i) + " ");
		}
		System.out.println();
		charbuffer1.append("我是只读的，不能添加数据");
	}

}
